package com.ruoyi.accountant.mapper;

import com.ruoyi.accountant.domain.ReasonDetail;
import com.ruoyi.accountant.domain.ReasonDetailExample;
import java.util.List;

import com.ruoyi.accountant.domain.other.ProfitLossReport;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface ReasonDetailMapper {
    int countByExample(ReasonDetailExample example);

    int deleteByExample(ReasonDetailExample example);

    int deleteByPrimaryKey(Long rid);

    int insert(ReasonDetail record);

    int insertSelective(ReasonDetail record);

    List<ReasonDetail> selectByExample(ReasonDetailExample example);

    ReasonDetail selectByPrimaryKey(Long rid);

    int updateByExampleSelective(@Param("record") ReasonDetail record, @Param("example") ReasonDetailExample example);

    int updateByExample(@Param("record") ReasonDetail record, @Param("example") ReasonDetailExample example);

    int updateByPrimaryKeySelective(ReasonDetail record);

    int updateByPrimaryKey(ReasonDetail record);

    @Select("select t.month, t.money,tr.rname,t.tax from (select month(proof_date) as month, sum(main_currency_money) as money, of_reason, sum(tax) as tax\n" +
            "    from t_transaction_detail as t where of_reason = #{ofReason} and deleted = 0 group by of_reason, month(proof_date)) as t\n" +
            "        left outer join t_reason tr on tr.rid = t.of_reason where tr.rtype = #{type} ;")
     List<ProfitLossReport> findByTypeAndReason(@Param("type") String type, @Param("ofReason") Long ofReason);
}